package com;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.net.Socket;

public class Client {

    public static final int DEFAULT_PORT = 4321;

    public Socket clisoc;

    private Thread reader;

    public StringBuilder OutputArea;

    public PrintStream out;

    public String Name;

    public Client() {
        init();
    }

    public static void main(String[] args) {
        new Client();
    }

    private void init() {
        try {
            //Cria um socket cliente passando o endereco e a porta do servidor
            clisoc = new Socket("127.0.0.1", DEFAULT_PORT);
            out = new PrintStream(clisoc.getOutputStream());
        } catch (IOException e) {
            System.err.println(e);
        }

        OutputArea = new StringBuilder();

        try {
            DataInputStream in = new DataInputStream(clisoc.getInputStream());
            DataOutputStream out = new DataOutputStream(clisoc.getOutputStream());

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        //        DataInputStream in = null;
        //        String line;
        //        try {
        //            in = new DataInputStream(clisoc.getInputStream());
        //            while (true) {
        //                line = in.readLine();
        //                //Adiciona a nova mensagem a OutputArea
        //                OutputArea.append(line + "\r\n");
        //            }
        //        } catch (IOException e) {
        //            System.out.println("Reader:" + e);
        //        }
    }
}
